<template>
  <div class="hello">
    <h2>这是HelloWorld组件</h2>
    <h2>{{$store.state.count}}</h2>
    <button @click="addTwo">点击+2</button>
    <button @click="updUser">修改</button>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  props: {
    msg: String,
    count:Number
  },
  methods:{
	  addTwo(){
		  // 触发mutations函数，指定额外参数
		  this.$store.commit({ //对象提交方式
			  type:"addTwo",
			  two:2
		  })
	  },
	  updUser(){
      // 触发mutations函数，指定额外参数
      this.$store.commit({ //对象提交方式
        type:"updUser"
      })
	  },
  }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.hello {
  border: 2px solid red;
  margin:15px;
}
</style>
